//获取数据库中所有商品列表
var tbody = document.querySelector('#shop-tbody')
getLIst()
function getLIst () {
    utils.fetch('./api/shop/select.php').then( resp => {
        
        if(resp.code === 200) {
            const {list} = resp.list
            tbody.innerHTML = list.reduce((html, shop, index) => {
                html += `
                <tr data-id="${shop.id}">
                <td>${index + 1}</td>
                <td><span id="edit-span-name">${shop.name}</span><input type="text" id="edit-shop-name"></td>
                <td><span id="edit-span-price">${shop.price}</span><input type="text" id="edit-shop-price"></td>
                <td><span id="edit-span-num">${shop.num}</span><input type="text" id="edit-shop-num"></td>
                <td>
                  <button class="btn btn-xs btn-primary btn-edit">编辑</button>
                  <button class="btn btn-xs btn-danger btn-del">删除</button>
                  <button class="btn btn-xs btn-info btn-ok">确定</button>
                  <button class="btn btn-xs btn-warning btn-cancel">取消</button>
                </td>
              </tr>
                `
                return html
            }, '')
        }
    })
}
